<div id="tb<?php echo $uniqid;?>" style="padding:5px">
		<table cellspacing="0" cellpadding="0"><tbody><tr>
		<td><SELECT id='newsclass_id' size='1' onchange="newssearch();">
				<OPTION value="0">所有栏目</OPTION>
				<OPTION value="0" disabled="disabled"> -------- </OPTION>
				<?php foreach($newsclass as $v):?>
				<OPTION value="<?php echo $v->id;?>"><?php echo $v->title;?>  : <?php echo $v->recordcount;?>篇</OPTION>
					<?php foreach($v->children as $vc):?>
					<OPTION value="<?php echo $vc->id;?>">&nbsp;&nbsp;|--<?php echo $vc->title;?>  : <?php echo $vc['recordcount'];?>篇</OPTION>
					<?php endforeach;?>
				<?php endforeach;?>
			</SELECT>
		</td>
		<?php if(checkAuth('添加文章')):?>
		<td><a href="javascript:;" onclick="addTab('添加文章', '/admin/news/newsadd');" class="l-btn l-btn-small l-btn-plain" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">增加</span><span class="l-btn-icon icon-add">&nbsp;</span></span></a></td><td><div class="datagrid-btn-separator"></div></td>
		<?php endif;?>
		<?php if(checkAuth('编辑文章')):?>
		<td><a href="javascript:;" onclick="newsedit('编辑文章');"  class="l-btn l-btn-small l-btn-plain" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">编辑</span><span class="l-btn-icon icon-edit">&nbsp;</span></span></a></td>
		<?php endif;?>
		<td><div class="datagrid-btn-separator"></div></td>
		<?php if(checkAuth('删除文章')):?>
		<td><a href="javascript:;" onclick="newsrecycle();"  class="l-btn l-btn-small l-btn-plain" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">冻结/恢复</span><span class="l-btn-icon icon-lock">&nbsp;</span></span></a></td><td><div class="datagrid-btn-separator"></div></td>
		<td><a href="javascript:;" onclick="newsdelete();"  class="l-btn l-btn-small l-btn-plain" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">删除</span><span class="l-btn-icon icon-cancel">&nbsp;</span></span></a></td><td><div class="datagrid-btn-separator"></div></td>
		<?php endif;?>
		<td><a href="javascript:;" onclick="newsreload();"  class="l-btn l-btn-small l-btn-plain" group="" id=""><span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">重载</span><span class="l-btn-icon icon-reload">&nbsp;</span></span></a></td>
		<td>&nbsp;&nbsp;<input  id="newskeywords"  style="width:100px" type="text" class= "easyui-input textbox" > </input></td>
		<td><span><a href="javascript:void(0)" class="easyui-linkbutton" plain="true" iconCls="icon-search" onclick="newssearch()">查询</a></span>	</td>
		</tr></tbody></table>
</div>

<div class="con"  style="-moz-user-select:none;">
    <table id="news"></table>
</div>

<div id="newsdlg" class="easyui-dialog" style="width:720px; height:460px;" title="信息框" closed="true"></div>

<script>
var newsedit=function(title){
				var row = $('#news').datagrid('getSelected');
				if (row){
						url	=	'/admin/news/newsedit?id='+row.id,
						$('#rightTabs').tabs('close',title);
						addTab(title,url);
				}else{
						$.messager.alert('提示','请先选择要编辑的行！','warning');
				}
}
var newsrecycle=function(){
				var row = $('#news').datagrid('getSelected');
				if (row){
					if(row.status==0){
							$.messager.confirm('提示','确定还原吗？',function(r){
								if(r==true){
									$.messager.progress();
									$.post('/admin/news/newsrecycle', {id:row.id}, function(data){
										$.messager.progress('close');
										if(data.code=='200'){
												$.messager.show({
														title:'提示',
														msg:data.msg,
														timeout:3000,
														showType:'slide'
												});
												newsreload();
										}else{
												$.messager.alert('提示',data.msg,'warning');
										}								
									},'json');
								}
							});
					}else{
							$.messager.confirm('提示','确定冻结吗？',function(r){
								if(r==true){
									$.messager.progress();
									$.post('/admin/news/newsrecycle', {id:row.id}, function(data){
										$.messager.progress('close');
										if(data.code=='200'){
												$.messager.show({
														title:'提示',
														msg:data.msg,
														timeout:3000,
														showType:'slide'
												});
												newsreload();
										}else{
												$.messager.alert('提示',data.msg,'warning');
										}								
									},'json');
								}
							});
					}
                }else{
						$.messager.alert('提示','请先选择要扔回收站的行！','warning');
				}
}
var newsdelete=function(){
				var row = $('#news').datagrid('getSelected');
				if (row){
                    $.messager.confirm('提示','确定删除吗？',function(r){
                        if(r==true){
                            $.messager.progress();
                            $.post('/admin/news/newsdelete', {id:row.id}, function(data){
                                $.messager.progress('close');
								if(data.code=='200'){
										$.messager.show({
												title:'提示',
												msg:data.msg,
												timeout:3000,
												showType:'slide'
										});
										newsreload();
								}else{
										$.messager.alert('提示',data.msg,'warning');
								}								
                            },'json');
                        }
                    });
                }else{
						$.messager.alert('提示','请先选择要删除的行！','warning');
				}
}
var newsreload=function(){
                $("#news").datagrid('reload');
}
var newssearch=function(){
		var height=	$(window).height()-$(".top").height()-121;
		var width = $(window).width()-$("#leftMenu").width()-13;
        $("#news").datagrid({
            title:'新闻管理',
            width:width,
            height:height,//高度
            singleSelect:true,//如果为true，则只允许选择一行
            striped:true,//是否显示斑马线效果。
            rownumbers:true,//如果为true，则显示一个行号列。
            pagination:true,//是否显示分页
            pageSize:10,
            pageList:[10,15,20,25],
            method:'post',
            sortName:'sortorder',
            sortOrder:'desc',
            url:'/admin/news/newsGet',
			queryParams : {keywords:$('#newskeywords').val(),newsclass_id:$('#newsclass_id').val()},
            fitColumns:true,//真正的自动展开/收缩列的大小，以适应网格的宽度，防止水平滚动。
            nowrap:true,//如果为true，则在同一行中显示数据。设置为true可以提高加载性能。 是否换行
            selectOnCheck:false,
            checkOnSelect:true,
			toolbar: '#tb<?php echo $uniqid;?>',
			rowStyler: function(index,row){
					if (row.deleted_at!='0000-00-00 00:00:00'){
						return 'color:#F00;font-style:italic;';
					}
			},
            columns:[[
                {field:'title',title:'名称',width:'30%'},
				{field:'classname',title:'栏目',width:'5%'},
				{field:'author',title:'作者',width:'5%'},
                {field:'keywords',title:'关键词',width:'15%'},
				{field:'status',title:'状态',width:'5%',formatter:function (value,rowData,rowIndex){
					if(value==1){
						  	return '激活';
					}else{
						  	return '冻结';
					}
				}},
				{field:'sortorder',title:'排序',width:'5%',sortable:true},				
				{field:'created_at',title:'创建时间',width:'10%',sortable:true},
				{field:'updated_at',title:'更新时间',width:'10%',sortable:true},
            ]],
			onDblClickRow : function(index,field){					
				newsedit('编辑文章');
			} 
    	});
}
newssearch();
</script>
